import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity, Index, OneToMany } from 'typeorm';
import { CommonEntity } from '~/common/entity/common.entity';
import { DictItemEntity } from '../dict-item/dict-item.entity';
import { Exclude } from 'class-transformer';

@Entity({ name: 'ah_label_type' })
@Index(['id'])
export class DictTypeEntity extends CommonEntity {
  @Column({ type: 'varchar', length: 50 })
  @ApiProperty({ description: '字典名称' })
  name: string;

  @Column({ type: 'varchar', length: 50, unique: true })
  @ApiProperty({ description: '字典类型' })
  code: string;

  @Column({ type: 'tinyint', default: 1 })
  @ApiProperty({ description: ' 状态' })
  status: number;

  @Column({ type: 'varchar', nullable: true })
  @ApiProperty({ description: '备注' })
  remark: string;

  @Exclude()
  @OneToMany(() => DictItemEntity, (dictItem) => dictItem.type)
  items: DictItemEntity[];
}
